<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增车辆主要信息')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-carmain-add">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">vin码(主键)：</label>
                <div class="col-sm-8">
                    <input name="vin" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">车辆公告型号：</label>
                <div class="col-sm-8">
                    <input class="form-control" name="carTypeId">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">车辆预配置id：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="configId" id="configid">

                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">车辆种类：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="carKindId">

                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">电池包编号：</label>
                <div class="col-sm-8">
                    <input name="carCellId" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">驱动机编号：</label>
                <div class="col-sm-8">
                    <input name="carMotorId" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">终端编号：</label>
                <div class="col-sm-8">
                    <input name="carTerminalId" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">ICCID：</label>
                <div class="col-sm-8">
                    <input class="form-control" type="text">
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label">生产批次号：</label>
                <div class="col-sm-8">
                    <input name="vendorBatch" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">下线质检状态 0通过  1未通过</label>
                <div class="col-sm-8">
                    <select class="form-control" name="carQualityStatus">
                        <option value="0">通过</option>
                        <option value="1">未通过</option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">车辆合格证编号：</label>
                <div class="col-sm-8">
                    <input name="carQualifiedCode" class="form-control" type="text">
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label">整车保质期：</label>
                <div class="col-sm-8">
                    <input name="carExpirationDate" class="form-control" type="text">
                </div>
            </div>


        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "carmain/carmain"
        $("#form-carmain-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-carmain-add').serialize());
            }
        }

        $(function(){
            $.ajax({
                url:'/carmain/carmain/carkind',
                type:"get",
                dataType:"json",
                success:function (d){
                    for(var i in d){
                        $("[name='carKindId']").append("<option value='"+d[i.id]+"'>"+d[i].kindName+"</option>");
                    }
                }
            });

            $.post(
                "/car/config/listconfigName",
                function (obj) {
                    for(var i in obj){
                        $("[name='configId']").append("<option value='"+obj[i].id+"'>"+obj[i].configName+"</option>");
                    }
                },
                "json"
            )
            $("[name='configId']").change(function () {
                var id = $("#configid").val();
                   $.post(
                       "/carmain/carmain/carMainFindOne",
                       {id:id},
                       function (obj) {
                           $("[name='carCellId']").val(obj.batteryPackId);
                           $("[name='carMotorId']").val(obj.batteryPackId);
                           $("[name='carTerminalId']").val(obj.motorId);
                       },
                       "json"
                   )
            })


        });

    </script>
</body>
</html>
